package railRoad.web.tags;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspTagException;
import javax.servlet.jsp.tagext.TagSupport;

import railRoad.Ticket;

public class TicketTypeTag extends TagSupport {

	static final long serialVersionUID = 1L;

	private Ticket ticket = null;
	
	public Ticket getTicket() {
		return ticket;
	}

	public void setTicket(Ticket ticket) {
		this.ticket = ticket;
	}

	@Override
	public int doStartTag() throws JspException {

		if (ticket != null) {
		try {
				pageContext.getOut().print(ticket.getTypeName());
			} catch (Exception ex) {
				throw new JspTagException("SimpleTag: " + ex.getMessage());
			}
			return SKIP_BODY;
		}

		return super.doStartTag();
	}

	@Override
	public int doEndTag() {
		return EVAL_PAGE;
	}
}
